package com.richard.library.http.request;

import okhttp3.Response;

/**
 * @author: Richard
 * @createDate: 2024/9/6 10:59
 * @version: 1.0
 * @description: http 响应参数对象封装
 */
public final class Result<T> {

    /**本次请求响应体*/
    private final Response response;

    /**本次响应body数据，请求下载文件时为空*/
    private final T data;

    /**出现异常时为具体异常信息*/
    private final Throwable th;

    public Result(Response response, T data, Throwable th) {
        this.response = response;
        this.data = data;
        this.th = th;
    }

    public boolean isError(){
        return th != null;
    }

    public Response response() {
        return response;
    }

    public T data() {
        return data;
    }

    public Throwable error() {
        return th;
    }
}
